<?php
/**
 * Created by PhpStorm.
 * User: sunshubo
 * Date: 2017/12/12
 * Time: 9:57
 */

class GetActiveList_model extends MY_Model
{
    function get_active_list()
    {
//        $table = 'ws_active_list';
//        $field = 'id,title,start_date,end_date,share_total,look_total,data';
//        $res = $this->my_select($table, null, $field);
        $sql = /** @lang text */
            "SELECT COUNT(a.`id`) AS 'join',a.`id`,a.`title`,a.`share_total`,a.`look_total`,a.`data`,a.`type`,a.`start_date`,a.`end_date`,a.`active_date`, DATEDIFF(a.`start_date`,DATE_FORMAT(NOW(),'%Y-%m-%d')) AS start, DATEDIFF(a.`end_date`,DATE_FORMAT(NOW(),'%Y-%m-%d')) AS surplus FROM ws_active_list a LEFT JOIN ws_active_record b ON a.`id`=b.`aid` GROUP BY a.`id` ORDER BY a.id DESC";

        $query = $this->db->query($sql);
        if ($query) {
            return $query->result_array();
        }
        return false;
    }
}